<template>
	<div :id="id" class="badgeWhite baseContent" v-if="dataRend" v-loading="active">
		<basetitle>
			<slot slot="left">{{ dataRend.name }}</slot>
			<slot slot="right">
				<div class="rightFontCont"><i class="iconfont icon-shuaxin1 rightFont" @click="refreshFull(dataRend.prn)"></i></div>
			</slot>
		</basetitle>
		<div class="baseCont">
			<div class="chart-container baseRelative overAuto" :style="{ height: dataRend.itemData.height != '' ? dataRend.itemData.height : defalutHeight }">
				<ListplateFive v-for="(item, index) in dataRend.itemData.list" :key="index">
					<slot slot="left">
						<span class="iconfont icon-dian1" :class="[item.ReadorNot == 'Y' ? 'colorGreen' : '']"></span>
						<span class="hoverText" @click="getUrl(item)" :class="[item.ReadorNot == 'Y' ? 'colorNoticeTitl' : '']">{{ item.text }}</span>
					</slot>
					<slot slot="right">{{ item.date }}</slot>
				</ListplateFive>
			</div>
		</div>
		<DolgNotice ref="dolgNotice"/>
	</div>
</template>
<script>
import { generateMixed } from '@/utils/index.js';
 const basetitle =()=>import('@/components/basetitle/index.vue')//
 const ListplateFive =()=>import('@/components/Listplate/ListplateFive.vue')//文字列表样式
import store from '../../../store';
import { mapState, mapActions,mapMutations } from 'vuex';
import { getHomePage, refreshContent,NoticePreview} from '../../../api/config.js';
import DolgNotice from '@/components/DolgNotice/index.vue';
import { getFromCache } from '@/utils/cache.js';
export default {
	name: 'noticeList',
	mixins: [],
	props: {
		className: {
			type: String,
			default: 'baseId' + generateMixed('8')
		},
		id: {
			type: String,
			default: 'baseId' + generateMixed('8')
		},
		width: {
			type: String,
			default: '200px'
		},
		defalutHeight: {
			type: String,
			default: '300px'
		},
		itemdata: {
			default: Object
		},
		itemStyle: {
			default: Object
		}
	},
	components: {
		basetitle,
		ListplateFive,
		DolgNotice
	},
	data() {
		return {
			listQuery: {
				page: 1,
				limit: 20,
				importance: undefined,
				title: undefined,
				type: undefined,
				sort: '+id'
			},
			list: null,
			total: 1,
			tabPosition: 'top',
			dataRend: '',
			active:false
		};
	},
	computed: {
		...mapState({
			mainRend: state => store.state.base.mainRend
		})
	},
	beforeDestroy() {},
	mounted() {
		this.dataRend = this.itemdata;
	},
	methods: {
		...mapActions('base', ['getIndexRend']),
		...mapActions('dolgnotice', ['savedata']),
		...mapMutations('dolgnotice', ['saveOpen']),
		refreshFull(type) {
		  let that = this;
		  that.active=true;
		  let parms = {};
		  parms.type = type;
      parms.user_prn = JSON.parse(getFromCache('userInfo')).env$user_prn;
		  that.$post(refreshContent, parms).then(response => {
			setTimeout(function () {
				that.active=false;
				},2000);
			  if (response.status === false){
				  that.$message.error(response.error[0]);
				  return
				}
				that.dataRend = response.obj;
			});
		},
		getList() {

		},
		getUrl(item) {
			let that=this;
			let parmas={};
			parmas.prn=item.prn;
			parmas.plate_prn =this.dataRend.prn;
			that.$post(NoticePreview,parmas).then(response => {
				console.log(response)
				if(response.status==true){
					let datas=response.obj;
					that.savedata(datas)
					this.$refs.dolgNotice.showModel()
				}else{
					 this.$message({
						  message:response.error,
						  type: 'warning'
						});
				}
			});
		}
	},
	watch: {
		mainRend() {
			this.dataRend = this.mainRend;
		}
	}
};
</script>

<style></style>
